<?php

global $_W, $_GPC;
$mid = intval($_GPC['mid']);
$openid = m('user')->getOpenid();
$member = m('member')->getInfo($openid);
$shop_set = m('common')->getSysset('shop');

$can = false;
if ($member['isagent'] == 1 && $member['status'] == 1) {
    $can = true;
}
if (!$can) {
    header("location: " . $this->createPluginMobileUrl('commission/register'));
    die;
}

if($_W['isajax']){
    $returnurl = urlencode($this->createPluginMobileUrl('commission/sharesx', array('goodsid' => $_GPC['goodsid'])));
    $infourl = "";
    $set = $this->set;
    if (empty($set['become_reg'])) {
        if (empty($member['realname']) || empty($member['mobile'])) {
            $infourl = $this->createMobileUrl('member/info', array('returnurl' => $returnurl));
        }
    }

    $p = p('poster');

    $img = $p->createCommissionPoster($openid);
    //为适应新版调整
    //$img = is_array($img) && isset($img['qrimg']) ? $img : array('qrimg' => $img);

    die($img);
}

include $this->template('sharesx');